#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int randint1(){
	srand(time(NULL));
    int num=(rand()%99)+1;
    return num;	
}
int guess(int num,int num1){
	if (num>num1){
		return 1;
	}
	else if(num==num1){
		return 0;
	}
	else
	 return -1;
}
void assess(int times){
	if (times<5){
	 	printf("你是天才！\n");
	 }
	else if (times>=5 && times<8)
	   {
	   	printf("运气很好！\n");
	   }
	else if (times>=8 && times<10)
	   {
	   printf("你是一般人！\n"); 
}
	 else 
	 {
	 printf("你是笨蛋！\n"); 
}
	   } 

//void assess()
int main(){
	int play=1;
	do{
//	int play=1;
	int num=randint1();
	//printf("%d\n",num);
	int times=0,guess_number;
	printf("欢迎来到猜数游戏\n");
	printf("请输入一个1到99的数字:\n");
	//scanf("%d",&guess_number);
	do{
	   printf("请输入猜测数：\n");
	   scanf("%d",&guess_number);
	   times++;
	   int result=guess(num,guess_number);
	  if(result==1){
	  	printf("你猜小了.");
	  }
	   else if(result==-1){
		printf("你猜大了.");
     }
	  else {
	   printf("恭喜猜对\n.");
	   break;
	   }
	   int i;
	   if (times>4){
	   	printf("是否看答案：1.是 2.否\n");
	   	scanf("%d",&i);
	   	if(i==1){
	   		printf("答案为：%d\n",num);
		   }
		else
		printf("请继续加油！\n");
	   }
	} while(1);
	   printf("你猜了%d次!",times);
	 assess(times);
	//printf("%d",num);
	  printf("是否在玩一次？1.是  2. 否\n");
	  scanf("%d",&play);
	  }while(play==1);
	return 0;
}
